package org.villacoapa.util
{
	import mx.formatters.DateFormatter;
	
	public class DateUtil
	{
		
		/**
		 * Recibe una cadena con formato yyyy-mm-dd y la convierte a Date de Flex
		 */
		public static function createDateFromJavaDateStr(jdate:String):Date{
			var year:Number = Number(jdate.substring(0,4));
			var month:Number = Number(jdate.substring(5,7));
			var day:Number = Number(jdate.substring(8,10));
			var date:Date = new Date();
			date.setFullYear(year,month-1,day);
			return date;
		}
		
		public static function formatDate(date:Date):String{
			var df:DateFormatter = new DateFormatter();
			df.formatString = "DD-MM-YYYY";
			return df.format(date);
		}

	}
}